Skip to content

Conversation

csehatt741
Copy link
Contributor

@csehatt741 csehatt741 commented Sep 10, 2025

Summary

A new feature was implemented to enable multiple canvases in the canvas editor.

  • SliceConfig was updated in types.js to handle partially undoable slices:
    • new generic parametes, TInternalState and TSerializedState, were added to strongly type states used in Redux and the persisted into storage
    • new functions, wrapState and unwrapState, were added to the migrate field for wrapping/unwrapping state during serialization/deserialization
    • undoableConfig was deleted, as reduxUndoOptions is used only in slices, so this field became redundant
  • store.ts was refactored to use the updated SliceConfig
  • new schemas, zStateWithHistory, zCanvasStateWithHistory, zCanvasesState, zCanvasesStateWithHistory and zCanvasesStateWithoutHistory, were created in types.ts to represent types in the partially undoable canvases slice
  • new selectors, selectCanvases selectSelectedCanvasWithHistory and selectSelectedCanvas, were added to selectors.ts to isolate changes due to refactoring in the canvas slice from components
  • canvasSlice was split into two parts representing the canvases slice without history and the canvas with undoable history
  • undoableCanvasesReducer higher order reducer was created to combine canvases and canvas reducers
  • RTK was updated to version 2.9.0

Related Issues / Discussions

Closes #8380

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions bot added frontend-deps PRs that change frontend dependencies frontend PRs that change frontend files labels Sep 10, 2025
@csehatt741 csehatt741 changed the title feat(ui): canvas slice refactored to support tabbed canvases feat(ui): tabbed canvases Sep 10, 2025
@csehatt741 csehatt741 force-pushed the feat/tabbed-canvases branch 4 times, most recently from 3f40a1b to 1f9019d Compare September 16, 2025 09:07
@csehatt741 csehatt741 force-pushed the feat/tabbed-canvases branch 2 times, most recently from 2b8c8d2 to 03b85da Compare September 23, 2025 10:45
@csehatt741
Copy link
Contributor Author

csehatt741 commented Sep 24, 2025

@psychedelicious, here is the current status of multi-canvas development and refactoring:

  • to limit the scope of refactoring I still kept the notion of the active canvas
    • it always provides scope for any components even not in CanvasInstanceContext, without refactoring the component hierarchy
    • functionality can still be improved further in the future
  • canvasSlice:
    • state is split into per canvas instance state
    • undo/redo per canvas implemented
  • canvasStagingAreaSlice state is split into per canvas instance state
  • canvasSettingsSlice state is split into shared and per canvas instance state

Outstanding tasks:

  • paramsSlice refactoring
    • now it is shared among all the tabs (generate, canvas, upscaling)
    • I expect it should be separated per tabs/canvas instances. Is it a valid idea?
  • inject context related params by dispatchers
  • revise code where selectSelectedCanvas selector is used
    • there might be context that overrides the default selected canvas one
    • functionality might use all the canvases now, eg.: state.getImageUsage

@csehatt741
Copy link
Contributor Author

Since there is always only one canvas rendered, the active one, so the CanvasManager is created and initialized when the canvas is displayed and destroyed when the canvas becomes inactive.
Though, I haven't seen any issues caused by this lifecycle of the CanvasManager yet, but I expect this might lead to problems:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend PRs that change frontend files frontend-deps PRs that change frontend dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[enhancement]: Tabbed Canvases
1 participant